<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>商品分类</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link href="__PUBLIC__/css/layui.css" rel="stylesheet" type="text/css"/>
    <link href="__PUBLIC__/css/admin.css" rel="stylesheet" type="text/css"/>
    <link href="__PUBLIC__/css/public.css" rel="stylesheet" type="text/css"/>
    <style>
    html,body{
        height: 100%;
    }
    thead tr .layui-table-cell{
        height: 100%;
        font-size: 18px;
        line-height: 50px;
    }
    .layui-table-view .layui-table td, .layui-table-view .layui-table th{
        padding: 10px 0px;
    }
    </style>
</head>
<body style="height: 100%;">
<div class="layui-conter" style="height: 95%;">
    <div class="layui-col-md12" style="height: 100%;">
        <div class="navigation">
            <span>行政></span><span>仓库管理></span><span>商品分类</span>
        </div>
        <div class="white-conter" style="height: 100%;">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="title-blue"><b>商品分类</b></div>
                    <div class="layui-card-body addPadding" style="padding-right: 300px;">
                        <form class="layui-form" method="post" action="{:U('Warehouse/goodsAdd')}" lay-filter="component-form-group">
                            <div class=" layui-row" style="margin-top: 20px;position: relative;">
                                <div class=" layui-col-xs3">
                                    <label class="layui-form-label">商品分类：</label>
                                    <div class="layui-input-block">
                                            <input type="text" name="name" placeholder="请输入..." class="layui-input" >
                                    </div>
                                </div>
                                <div class=" layui-col-xs3">
                                    <label class="layui-form-label">商品单位：</label>
                                    <div class="layui-input-block">
                                            <input type="text" placeholder="请输入..." name="company" class="layui-input" >
                                    </div>
                                </div>
                                <div class=" layui-col-xs3">
                                    <label class="layui-form-label">开启状态：</label>
                                    <div class="layui-input-block">
                                        <select name="state">
                                            <option value="请选择" selected=""></option>
                                            <option value="0">开启</option>
                                            <option value="1">关闭</option>
                                        </select>
                                    </div>
                                </div>
                                <button class="layui-btn layui-btn-sm layui-btn-normal" style="position: absolute;right:380px;">添加</button>
                            </div>
                        </form>
                    </div>
                </div>
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-body">
                            <table  class="layui-hide" id="test-table-operate" lay-filter="test-table-operate"></table>
                            <div class="layui-form layui-border-box layui-table-view" lay-filter="LAY-table-1">
                                <div class="layui-table-box" style="margin-bottom: 20px">
                                    <div class="layui-table-body layui-table-main">
                                        <table cellspacing="0" cellpadding="0" border="0" class="layui-table">
                                            <thead>
                                            <tr>
                                                <th data-field="w-id">
                                                    <div class="layui-table-cell laytable-cell-w-id">
                                                        <span>编号</span>
                                                    </div>
                                                </th>
                                                <th data-field="w-goodscassify">
                                                    <div class="layui-table-cell laytable-cell-w-goodscassify" align="center">
                                                        <span>商品分类</span>
                                                    </div>
                                                </th>
                                                <th data-field="w-unit2">
                                                    <div class="layui-table-cell laytable-cell-w-unit2" align="center">
                                                        <span>商品单位</span>
                                                    </div>
                                                </th>
                                                <th data-field="w-state2">
                                                    <div class="layui-table-cell laytable-cell-w-state2" align="center">
                                                        <span>开启状态</span>
                                                    </div>
                                                </th>
                                                <th data-field="w-sort">
                                                    <div class="layui-table-cell laytable-cell-w-sort" align="center">
                                                        <span>排序</span>
                                                    </div>
                                                </th>
                                                <th data-field="operation">
                                                    <div class="layui-table-cell laytable-cell-operation" align="center">
                                                        <span>操作</span>
                                                    </div>
                                                </th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <foreach name="data" item="v">
                                                <tr data-index="0" id="{$v.id}" class="myclass">
                                                    <td data-field="w-id" align="center">
                                                        <div class="layui-table-cell laytable-cell-w-id">{$v.id}</div>
                                                        <input id="id" type="hidden" value="{$v.id}">
                                                    </td>
                                                    <td data-field="w-goodscassify" align="center">
                                                        <div class="layui-table-cell laytable-cell-w-goodscassify" style="height:100%;">
                                                             <input type="text" id="name" value="{$v.name}" class="layui-input" >
                                                        </div>
                                                    </td>
                                                    <td data-field="w-unit2" align="center">
                                                        <div class="layui-table-cell laytable-cell-w-unit2"  style="height:100%;">
                                                            <input type="text" id="company" value="{$v.company}" class="layui-input" >
                                                        </div>
                                                    </td>
                                                    <td data-field="w-state2" align="center">
                                                        <div class="layui-table-cell laytable-cell-w-state2" style="height:100%;overflow:visible;">
                                                            <select name="quiz1" id="quizl">
                                                                <option value="0" <if condition="$v.state eq 0 "> selected </if>>启用</option>
                                                                <option value="1" <if condition="$v.state eq 1 "> selected </if>>关闭</option>
                                                            </select>
                                                        </div>
                                                    </td>
                                                    <td data-field="w-sort" align="center">
                                                        <div class="layui-table-cell laytable-cell-w-sort">
                                                            <input type="number" id="sort" value="{$v.sort}" class="layui-input" >
                                                        </div>
                                                        <!--↑↓-->
                                                    </td>
                                                    <td data-field="operation" align="center">
                                                        <div class="layui-table-cell laytable-cell-operation">
                                                            <button data-method="offset" data-type="test8"  class="img-but edit-img" data-type="test8" lay-event="edit" onclick="editTable('{$v.id}')"></button>
                                                            <button data-method="offset" data-type="auto"  class="img-but del-img" onclick=window.location.href="{:U('Warehouse/del',array('id'=>$v['id']))}"></button>
                                                            <!--<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>-->
                                                            <!--<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" href="{:U('Warehouse/del',array('id'=>$v['id']))}">删除</a>-->
                                                        </div>
                                                    </td>
                                                </tr>
                                            </foreach>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>

                            <script type="text/html" id="test-table-operate-barDemo">
                                <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
                                <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
                                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
                            </script>
                        </div>
                    </div>
                </div>
            </div>
        </div>


    </div>
</div>
</body>
<script src="__PUBLIC__/js/layui.all.js"></script>
<script src="__PUBLIC__/js/jquery.min.js"></script>
<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#losedate' //指定元素
        });
    });

    function editTable(a)
    {
        var id = $('#'+a).find('#id').val();
        var name = $('#'+a).find('#name').val();
        var company = $('#'+a).find('#company').val();
        var quizl = $('#'+a).find('#quizl').val();
        var sort = $('#'+a).find('#sort').val();

        $.ajax({
            cache: true,
            type: "POST",
            url: "{:U('Warehouse/goodsedit')}",
            data:{"id":id ,"name":name,"company":company,"quizl":quizl,"sort":sort},
            async: false,
            error: function(request) {
                alert("Connection error");
            },
            success: function(data) {
                window.location.href="{:U('Warehouse/goodsCassify')}";
            }
        });
    }
</script>
</html>